﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VietThinks.Model;

namespace VietThinks.Mapping.Maps
{
    public class RoleMap : DomainEntityMap<Role>
    {
        public RoleMap()
        {
            Schema("Admin");
            Table("Role");
            Map(m => m.Code);
            Map(m => m.Name);
            Map(m => m.Actived);
            Map(m => m.CreatedDate);
            Map(m => m.ModifiedDate);
            //HasManyToMany(m => m.Rights)
            //   .Schema("Admin")
            //   .Table("RightInRole")
            //   .ChildKeyColumn("RightId")
            //   .ParentKeyColumn("RoleId")
            //   .BatchSize(10);
            HasMany(m => m.Rights)
                .KeyColumn("RoleId")                
                .Inverse()
                .Cascade.AllDeleteOrphan()
               ;
        }
    }
}
